package cn.com.homeyoda.aimate.aihealth.ui.health.adapter;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.WeekBean;


public class WeekSelectAdapter extends BaseQuickAdapter<WeekBean, BaseViewHolder> {

    private int selectPosition = 0;

    public WeekSelectAdapter(int layoutResId, @Nullable List<WeekBean> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, WeekBean item) {
        helper.setText(R.id.tv_week, item.getWeekName());
        helper.setText(R.id.tv_day, item.getDay());

        if (item.getWeekName().equals("周六") ||
                item.getWeekName().equals("周日")
        ) {
            helper.setTextColor(R.id.tv_day, mContext.getResources().getColor(R.color.black_20));
        }else{
            helper.setTextColor(R.id.tv_day, mContext.getResources().getColor(R.color.black_60));
        }

        if (selectPosition == helper.getAdapterPosition()) {
            helper.setBackgroundRes(R.id.tv_day, R.mipmap.icon_week_select);
            helper.setTextColor(R.id.tv_day, mContext.getResources().getColor(R.color.white));
        } else {
            helper.setBackgroundRes(R.id.tv_day, 0);
            helper.setTextColor(R.id.tv_day, mContext.getResources().getColor(R.color.black_60));
        }
    }

    public void setSelectPosition(int position) {
        selectPosition = position;
        notifyDataSetChanged();
    }

}
